package com.learn.framework.util;

import lombok.Getter;
import org.springframework.stereotype.Component;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class DateUtil {

    DateUtil(){
    }

    public static Timestamp getTime(){
        Date date    =   new Date();
        Timestamp timestamp =   new Timestamp(date.getTime());
        return timestamp;
    }

    public static long getLongTime(){
        Date date    =   new Date();
        return date.getTime();
    }

    public static String formatDateTime(long timeStamp, String format){
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        return dateFormat.format(timeStamp);
    }
}
